﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Media;
using System.Windows.Forms;
using Stone_Jumper.Properties;

namespace Stone_Jumper
{
    public partial class GameSettingsForm : Form
    {
        private readonly Dictionary<Button, Bitmap> _buttonFucusDictionary;
        private readonly Dictionary<Button, Bitmap> _buttonNoFucusDictionary;
        private readonly MainMenu _mainMenu;
        public GameSettingsForm(MainMenu mainMenu)
        {
            this._mainMenu = mainMenu;
            InitializeComponent();
            _buttonFucusDictionary = new Dictionary<Button, Bitmap>()
            {
                {soundSet, new Bitmap((Properties.Resources.soundOnFocus), 200, 60)},
                {resetScore, new Bitmap((Properties.Resources.resetGameFocus), 200, 60)},
                {backButton, new Bitmap((Properties.Resources.backFocus), 200, 60)},
              
            };
            _buttonNoFucusDictionary = new Dictionary<Button, Bitmap>()
            {
                  {soundSet, new Bitmap((Properties.Resources.soundOnNoFocus), 200, 60)},
                {resetScore, new Bitmap((Properties.Resources.resetGameNoFocus), 200, 60)},
                {backButton, new Bitmap((Properties.Resources.backNoFocus), 200, 60)},
            };
            foreach (Button button in _buttonNoFucusDictionary.Keys)
            {
                button.BackgroundImage = _buttonNoFucusDictionary[button];
            }
            StartPosition = FormStartPosition.CenterScreen;
            var titleImage = new Bitmap(Resources.settingsFocus, TitleBox.Width, TitleBox.Height);
      
            TitleBox.Image = titleImage;
            this.TopMost = true;
            this.FormBorderStyle = FormBorderStyle.None;
            Cursor.Hide();

            backButton.PreviewKeyDown += Back;

        }

        private void ChangeFocus(object sender, EventArgs e)
        {

            var button = sender as Button;
            if (button != null)
            {
                button.BackgroundImage = !button.Focused
                ? _buttonFucusDictionary[button]
                : _buttonNoFucusDictionary[button];
            }
            new
                SoundPlayer(Resources.buttonChange).Play();

        }
        private void Back(object sender, PreviewKeyDownEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                this.Close();
                new
               SoundPlayer(Resources.buttonChange).Play();
               _mainMenu.Show();
            }
        }
       
    }
}
